/*
 * Copyright (c) 2023, 2023,yzc.cn All rights reserved.
 *
 */
package com.crmapi.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;

import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * <p>Project: CRMSystem - MvcConfig</p>
 * <p>Powered by yzc On 2023-11-16 09:56:05</p>
 * <p>描述：<p>
 *
 * @author yzc [yzc0415@126.com]
 * @version 1.0
 * @since 17
 */

public class MvcConfig implements WebMvcConfigurer {
    //@Override
    //public void addCorsMappings(CorsRegistry registry) {
    //    registry.addMapping("/**") //拦截所有请求
    //            .allowedHeaders("*")  //允许的请求头
    //            .allowedOrigins("*")  //允许来自哪些域名的请求  *所有域名
    //            .allowedMethods("GET","POST","PUT","DELETE","OPTIONS") //允许哪些方法跨域处理 OPTIONS预减请求
    //            .maxAge(3600);
    //    WebMvcConfigurer.super.addCorsMappings(registry);
    //}
    //@Bean
    //public CorsFilter corsFilter() {
    //    CorsConfiguration config = new CorsConfiguration();
    //    // 设置允许跨域请求的域名
    //    config.addAllowedOrigin("*");
    //    // 是否允许证书
    //    config.setAllowCredentials(false);
    //    // 设置允许的方法
    //    config.addAllowedMethod("*");
    //    // 允许任何头
    //    config.addAllowedHeader("*");
    //    UrlBasedCorsConfigurationSource configSource = new UrlBasedCorsConfigurationSource();
    //    configSource.registerCorsConfiguration("/**", config);
    //    return new CorsFilter(configSource);
    //}
}
